#include <UnitTest++/UnitTest++.h>
#include "../ArgumentRecord.h"
#include "../CompareFunctions.h"

using namespace MockItNow;

namespace
{
	TEST (EvaluateThrowsExceptionIfRecordParameterIsMissing)
	{
		ArgumentRecord<int, TypeInfo<int>::CompareFunction> record(&CompareByValue);
		record.ReplayArgument(5);

		CHECK(record.Evaluate().length() != 0);
	}

	TEST (EvaluateThrowsExceptionIfReplayParameterIsMissing)
	{
		ArgumentRecord<int, TypeInfo<int>::CompareFunction> record(&CompareByValue);
		record.RecordArgument(5);

		CHECK(record.Evaluate().length() != 0);
	}

	TEST (EvaluateSucceedsIfCompareFunctionIsMissing)
	{
		ArgumentRecord<int, TypeInfo<int>::CompareFunction> record(0);
		record.RecordArgument(5);
		record.ReplayArgument(5);

		CHECK(record.Evaluate().length() == 0);
	}

	TEST (EvaluateSucceedsWithValidData)
	{
		ArgumentRecord<int, TypeInfo<int>::CompareFunction> record(&CompareByValue);
		record.RecordArgument(5);
		record.ReplayArgument(5);

		CHECK(record.Evaluate().length() == 0);
	}

	TEST (EvaluateThrowsAnExceptionIfCompareFails)
	{
		ArgumentRecord<int, TypeInfo<int>::CompareFunction> record(&CompareByValue);
		record.RecordArgument(5);
		record.ReplayArgument(6);

		CHECK(record.Evaluate().length() != 0);
	}
}
